package com.hdax.dmw.scheduler.listener;

import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import com.hdax.dmw.entity.scheduler.TxMsg;
import com.hdax.dmw.scheduler.service.SchedulerSeatService;
import com.hdax.dmw.scheduler.service.TxMsgService;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@RabbitListener(queues = "order_tx_queue")
@Component
public class SeatChangeListener {

    @Autowired
    private SchedulerSeatService seatService;

    @RabbitHandler
    public void consume(Channel channel, Message message, String jsonStr) throws Exception{
        seatService.updateSeats(jsonStr);
        long deliveryTag = message.getMessageProperties().getDeliveryTag();
        //手动确认消息消费
        channel.basicAck(deliveryTag,false);

    }
}
